<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ProductItemDialog.aspx.vb" Inherits="MIMS_WRS.Web.ProductItemDialog" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>ProductItemDialog</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="../style.css" type="text/css" rel="stylesheet">
		<script language="javascript" src="../Js/common.js"></script>
		<script language="javascript" src="../Js/EventCapture.js"></script>
		<script language="javascript">
		
		<!--
		var productCodeLKID = <%= MIMS_WRS.Business.Common.GetProductCodeLKID %>;
		var supplierCodeLKID = <%= MIMS_WRS.Business.Common.GetSupplierCodeLKID %>;
		var mimsProductCodeLKID = <%= MIMS_WRS.Business.Common.GetMIMSProductCodeLKID %>;
		var productColorLKID = <%= MIMS_WRS.Business.Common.GetProductColorLKID %>;
		
		function rad_onclick(obj) {			
			
			var radTEXT = 'dgBOItems__ctl####_rdbSelected';
			var i = 2;			
			var objRad = window.document.getElementById(radTEXT.replace('####', i));			
			while (objRad) {
				if (objRad.id == obj.id) 
					objRad.checked = true;
				else
					objRad.checked = false;
				i++;
				objRad = window.document.getElementById(radTEXT.replace('####', i));
			}			
		}
				
		function calcBelowPosition(obj, w) {
			var retObj = new Object();
			retObj.left = event.screenX - event.offsetX;
			retObj.top = event.screenY + obj.offsetHeight - event.offsetY;
			return retObj;			
		}
		
		function NewProductCode(obj) {
			var w=420;
			var h=250;
			var lpos=(screen.width - w)/2
			var tpos=(screen.height - h)/2		

			var pos = calcBelowPosition(obj, w);			
			var reval;			
			var title="New Product code";			
			var cid='<%= CustomerID %>';
			var url=escape('ProductCodeDialog.aspx?cid='+cid);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
			
				document.all['txtPartOfBarcode'].value = reval.PartOfBarcode;
				document.all['txtProductCode'].value = reval.Code;				
				document.all['hidProductCodeID'].value = reval.ID;
				return true;
			}

			return false;
		}
		
		function OpenProductCodeList(obj) {
			var w=450;
			var h=300;
			var lpos=(screen.width - w)/2
			var tpos=(screen.height - h)/2		
			var pos = calcBelowPosition(obj, w);			
			var reval;			
			var title="Select Product code";
			var cid='<%= CustomerID %>';
			//var url=escape('ProductCodeListDialog.aspx?cid='+cid);
			var url=escape('Popup_Productcode.aspx?cid='+cid);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
				document.all['txtPartOfBarcode'].value = reval.PartOfBarcode;
				document.all['txtProductCode'].value = reval.Code;				
				document.all['hidProductCodeID'].value = reval.ID;
				return true;
			}
			return false;
		}

		function OpenProductColorList(obj,  textReturn, idReturn, title, w, h, id, valueno) {
			var pos = calcBelowPosition(obj, w);			
			var lpos=(screen.width - w)/2
			var tpos=(screen.height - h)/2		

			var reval;			
			var url=escape('Popup_Color.aspx?id='+id+'&t='+valueno);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
				textReturn.value = reval.Text;
				idReturn.value = reval.Value;
				return true;
			}
			return false
		}
		
		function OpenLKList(obj,  textReturn, idReturn, title, w, h, id, valueno) {
			var pos = calcBelowPosition(obj, w);			
			var reval;			
			var url=escape('LookupDataListDialog.aspx?id='+id+'&t='+valueno);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + pos.top + "px; dialogLeft: " + pos.left + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
				textReturn.value = reval.Text;
				idReturn.value = reval.Value;
				return true;
			}
			return false
		}
		
		function AddLK(obj, textReturn, idReturn, title, w, h, id, valueno) {
			var pos = calcBelowPosition(obj, w);
			var lpos=(screen.width - w)/2
			var tpos=(screen.height - h)/2		

			var reval;
			var url = escape('LookupDataInputDialog.aspx?id='+id);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			if (reval != null) {
				switch (valueno) {
					case 1:
						textReturn.value = reval.Value1;
						break;
					case 2:
						textReturn.value = reval.Value2;
						break;
					case 3:
						textReturn.value = reval.Value3;
						break;
				}
				idReturn.value = reval.ID;			
				return true;
			}
			return false
		}
		
		function QuantityCheck(src, arg) {
			var ddl=window.document.getElementById('ddlPackingNo');			
			arg.IsValid = (parseInt(arg.Value, 10) % parseInt(ddl.options[ddl.selectedIndex].text, 10) == 0)
		}
				
		//-->
		</script>
	</HEAD>
	<body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
		<form id="Form1" method="post" runat="server">
			<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
				<tr>
					<td class="bgwhite" align="center">
						<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
							<tr>
								<td vAlign="top" align="center">
									<table class="border1" height="100%" cellSpacing="2" cellPadding="2" width="100%" border="0">
										<tr>
											<td vAlign="top" align="center" bgColor="#f9f9f9">
												<!-- Main Table -->
												<table cellSpacing="0" cellPadding="3" width="100%" border="0">
													<TR class="bgmenu">
														<TD align="center" colSpan="3" height="30"><strong><asp:label id="lblTitle" runat="server" CssClass="txtnormal">Create new Product</asp:label></strong></TD>
													</TR>
													<TR>
														<TD class="txtnormal" align="right" width="37%"></TD>
														<TD align="center" width="1%"></TD>
														<TD class="txtnormal" width="62%"><asp:label id="lblStatus" runat="server" CssClass="txthighlight" Font-Bold="True"></asp:label></TD>
													</TR>
													<TR id="trBO" runat="server">
														<TD class="txtnormal" vAlign="top" align="right" width="37%">Use from BO#:</TD>
														<TD align="center" width="1%">&nbsp;</TD>
														<TD class="txtnormal" width="62%">
															<table cellSpacing="0" cellPadding="0" width="100%" border="0">
																<tr>
																	<td vAlign="top"><asp:dropdownlist id="ddlBO" runat="server" CssClass="txtsmall" AutoPostBack="True"></asp:dropdownlist></td>
																	<td><asp:datagrid id="dgBOItems" runat="server" AutoGenerateColumns="False" BorderWidth="1px" CellPadding="0"
																			BorderColor="LightGray">
																			<ItemStyle HorizontalAlign="Center" CssClass="txtsmall"></ItemStyle>
																			<HeaderStyle HorizontalAlign="Center" CssClass="txtsmall"></HeaderStyle>
																			<Columns>
																				<asp:TemplateColumn>
																					<HeaderStyle Width="1%"></HeaderStyle>
																					<ItemTemplate>
																						<input type=radio   onclick="rad_onclick(this);" runat=server id=rdbSelected  value='<%# DataBinder.Eval(Container, "DataItem.ID") %>' NAME="RadioGroup">
																					</ItemTemplate>
																				</asp:TemplateColumn>
																				<asp:BoundColumn DataField="ProductCode" HeaderText="Code"></asp:BoundColumn>
																				<asp:BoundColumn DataField="ProductDescription" HeaderText="Description"></asp:BoundColumn>
																				<asp:BoundColumn DataField="Color" HeaderText="Color"></asp:BoundColumn>
																				<asp:BoundColumn DataField="Quantity" HeaderText="Quantity"></asp:BoundColumn>
																			</Columns>
																		</asp:datagrid></td>
																</tr>
															</table>
														</TD>
													</TR>
													<tr id="trProCode" runat="server">
														<td class="txtnormal" align="right">Product Code:</td>
														<TD align="center" width="1%">&nbsp;</TD>
														<td>
															<table cellSpacing="0" cellPadding="0" border="0">
																<tr>
																	<td><asp:textbox id="txtProductCode" runat="server" CssClass="txtsmall" MaxLength="5" ReadOnly="True"
																			Width="120px"></asp:textbox></td>
																	<td><A onclick="OpenProductCodeList(this);" href="javascript:doNothing()"><IMG height="20" hspace="1" src="../images/b_browse.gif" width="22" border="0"></A><A onclick="NewProductCode(this);" href="javascript:doNothing()"><IMG height="20" hspace="4" src="../images/b_new.gif" width="72" border="0"></A></td>
																	<td><FONT class="txthighlight">* </FONT>
																		<asp:requiredfieldvalidator id="reqvProductCode" runat="server" CssClass="txthighlight" Display="Dynamic" ControlToValidate="txtProductCode"
																			ErrorMessage="Missing Product Code">required</asp:requiredfieldvalidator><INPUT class="txtsmall" id="hidProductCodeID" type="hidden" name="hidProductCodeID" runat="server"></td>
																</tr>
															</table>
														</td>
													</tr>
													<TR id="trPartofBarCode" runat="server">
														<TD class="txtnormal" align="right">Part of barcode:</TD>
														<TD align="center" width="1%"></TD>
														<TD><asp:textbox id="txtPartOfBarcode" runat="server" CssClass="txtsmall" BorderWidth="0px" MaxLength="5"
																ReadOnly="True" Width="64px" BorderStyle="None" BackColor="#F8F8F8">-- -- --</asp:textbox></TD>
													</TR>
													<TR id="trProColor" runat="server">
														<TD class="txtnormal" align="right">Color:</TD>
														<TD align="center" width="1%">&nbsp;</TD>
														<TD>
															<table cellSpacing="0" cellPadding="0" border="0">
																<tr>
																	<td><asp:textbox id="txtColor" runat="server" CssClass="txtsmall" MaxLength="12" ReadOnly="True"
																			Width="120px"></asp:textbox></td>
																	<td><A onclick="OpenProductColorList(this, window.document.getElementById('txtColor'), window.document.getElementById('hidColorID'), 'Select a product color', 450, 300, productColorLKID, 1)"
																			href="javascript:doNothing()"><IMG height="20" hspace="1" src="../images/b_browse.gif" width="22" border="0"></A><A onclick="AddLK(this, window.document.getElementById('txtColor'), window.document.getElementById('hidColorID'), 'Enter a new product color', 360, 160, productColorLKID, 1)"
																			href="javascript:doNothing()"><IMG height="20" hspace="4" src="../images/b_new.gif" width="72" border="0"></A></td>
																	<td><FONT class="txthighlight"> </FONT>
																		<asp:requiredfieldvalidator id="reqvProductColor" runat="server" CssClass="txthighlight" Display="Dynamic" ControlToValidate="txtColor"
																			ErrorMessage="Missing Product Color" Enabled="False">required</asp:requiredfieldvalidator><INPUT class="txtsmall" id="hidColorID" type="hidden" name="hidColorID" runat="server"></td>
																</tr>
															</table>
														</TD>
													</TR>
													<TR>
														<TD class="txtnormal" align="right">Packing:</TD>
														<TD align="center" width="1%">&nbsp;</TD>
														<TD><asp:dropdownlist id="ddlPackingNo" runat="server" CssClass="txtsmall">
																<asp:ListItem Value="1">1</asp:ListItem>
																<asp:ListItem Value="2">2</asp:ListItem>
																<asp:ListItem Value="3">3</asp:ListItem>
																<asp:ListItem Value="4">4</asp:ListItem>
																<asp:ListItem Value="5">5</asp:ListItem>
																<asp:ListItem Value="6">6</asp:ListItem>
																<asp:ListItem Value="7">7</asp:ListItem>
																<asp:ListItem Value="8">8</asp:ListItem>
															</asp:dropdownlist></TD>
													</TR>
													<TR>
														<TD class="txtnormal" vAlign="top" align="right">Quantity Ordered:</TD>
														<TD align="center" width="1%">&nbsp;</TD>
														<TD>
															<table cellSpacing="0" cellPadding="0" border="0">
																<tr>
																	<td><asp:textbox onkeypress="NumberOnly(0)" id="txtQuantity" runat="server" CssClass="txtsmall" MaxLength="5"
																			Width="72px"></asp:textbox></td>
																	<td><FONT class="txthighlight">* </FONT>
																	</td>
																	<td><asp:checkbox id="chkFixed" runat="server" CssClass="txtnormal" Font-Bold="True" Text="fixed"
																			Visible="False" Checked="False"></asp:checkbox>&nbsp;<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" CssClass="txthighlight" Display="Dynamic"
																			ControlToValidate="txtQuantity" ErrorMessage="Missing quantity">required</asp:requiredfieldvalidator>&nbsp;
																	</td>
																	<td class="txtcolor1">(You are able to adjust the&nbsp;quantity later)</td>
																</tr>
															</table>
															<asp:comparevalidator id="CompareValidator1" runat="server" CssClass="txthighlight" Display="Dynamic"
																ControlToValidate="txtQuantity" ErrorMessage="invalid number format" Operator="DataTypeCheck" Type="Integer"></asp:comparevalidator><asp:comparevalidator id="comvQuantity" runat="server" CssClass="txthighlight" Display="Dynamic" ControlToValidate="txtQuantity"
																ErrorMessage="Quantity must be greater than 0" Operator="GreaterThan" Type="Integer" ValueToCompare="0"></asp:comparevalidator><asp:customvalidator id="cusvQuantityCheck" runat="server" CssClass="txthighlight" Display="Dynamic"
																ControlToValidate="txtQuantity" ErrorMessage="Quantity must be a multiple number of packing" ClientValidationFunction="QuantityCheck"></asp:customvalidator></TD>
													</TR>
													<TR>
														<TD class="txtnormal" vAlign="top" align="right">Special Instructions:</TD>
														<TD align="center" width="1%">&nbsp;</TD>
														<TD colSpan="1"><asp:textbox onkeypress="MaxlengthTextArea(this, 2000)" id="txtSpecialInstruction" runat="server"
																CssClass="txtsmall" MaxLength="2000" Width="328px" Height="40px" TextMode="MultiLine"></asp:textbox><asp:regularexpressionvalidator id="regvSI" runat="server" CssClass="txthighlight" Display="Dynamic" ControlToValidate="txtSpecialInstruction"
																ErrorMessage="Special Instructions must not contain > or <" ValidationExpression="([^<>])*">must not contain > or <                                                                                                                                                                                                                                                                                                                                                                             </asp:regularexpressionvalidator></TD>
													</TR>
												</table>
												<!-- End of main table-->
												<TABLE cellSpacing="0" cellPadding="3" width="100%" border="0">
													<tr>
														<td height="50">&nbsp;</td>
													</tr>
													<TR class="txtnormal">
														<TD class="bgsubmenu" vAlign="bottom" align="right" height="20">All fields with red 
															mark (<span class="txthighlight">*</span>) are required fields.</TD>
													</TR>
												</TABLE>
												<table width="100%" align="center">
													<TR>
														<TD class="txtsmall" align="center" height="30"><asp:button id="btnOK" runat="server" CssClass="button" Text="Save"></asp:button>&nbsp;
															<INPUT class="button" onclick="window.close()" type="button" value="Cancel"></TD>
													</TR>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<asp:validationsummary id="valsValidationSummary" runat="server" HeaderText="Following error(s) are found:"
				ShowSummary="False" ShowMessageBox="True"></asp:validationsummary></form>
	</body>
</HTML>
